#include<iostream>
#include<opencv2\opencv.hpp>
using namespace cv;
using namespace std;
int main(){
	Mat m(255,255,CV_8UC3);
	/*第一种遍历方式
	*/
	for (int i = 0; i < m.rows; i++){
		for (int j = 0; j < m.cols; j++){
			Vec3b p;
			p[0] = rand()%255;
			p[1] = rand()%255;
			p[2] = rand() % 255;
			m.at<Vec3b>(i, j) = p;
		}
	}
	imshow("a", m);
	waitKey(6000);
	MatIterator_<Vec3b> next, end;
	for (next = m.begin<Vec3b>(), end = m.end < Vec3b > (); next != end; ++next){
		(*next)[0] = rand() % 255;
		(*next)[1] = rand() % 255;
		(*next)[2] = rand() % 255;
	}
	imshow("b", m);
	waitKey(6000);
	for (int i = 0; i < m.rows; ++i){
		uchar * p = m.ptr<uchar>(i);
		for (int j = 0; j < m.cols; ++j){
			p[j] = (i + j) % 255;
		}
	}
	imshow("c", m);
	waitKey(6000);
	return 0;
}